<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
    <style>

        p{
            font-size: 32px;
        }
        .p-d{
            background-color: #5898ff;
            width:100%;
            height:200px;
            display:table;
            text-align: center;

            margin-top: 300px;
            color: azure;
        }

        .p-c{
            background-color: #ffa932;
            width:100%;
            height:200px;
            display:table;
            text-align: center;

            margin-top: 300px;
            color: azure;
        }
        body{
            text-align: center;
        }
    </style>
</head>
<body>
<p>我要去掉这个城</p>
<input id="city-input" type="text" name="lastname">
<div class="p-d">
    <p>点我开始选城</p>
</div>

<div class="p-c">
    <p>点我开始模拟星官刷新</p>
</div>
</body>
<script>

    $(document).ready(function(){
        $(".p-d").click(function(){
            var city = [
                '长垣','直符','东萁','积卒',
                '御觞','斗井','七旒','咸池',
                '乐羽','南轸','析木','青丘',
                '女旦','牵古','仙歌','棂守',
                '定方','危盈','角白','玄枵',
                '龙旂','封豕','娄狱','北壁',
                '大仓','帛度','亢礼','西昂',
                '载衍','氐根','房宿','虎首',
                '水门','参伐','渊陈','烛光',
                '辰月','宣德','舆鬼','尾苍',
                '乌啄','上弼'
            ];

            var cName = $("#city-input").val();
            if(cName!=''){
                city.splice($.inArray(cName,city),1);
            }
            alert(city[Math.floor(Math.random()*42)]);
        });

        $(".p-c").click(function(){
            var city = [
                '长垣','直符','东萁','积卒',
                '御觞','斗井','七旒','咸池',
                '乐羽','南轸','析木','青丘',
                '女旦','牵古','仙歌','棂守',
                '定方','危盈','角白','玄枵',
                '龙旂','封豕','娄狱','北壁',
                '大仓','帛度','亢礼','西昂',
                '载衍','氐根','房宿','虎首',
                '水门','参伐','渊陈','烛光',
                '辰月','宣德','舆鬼','尾苍',
                '乌啄','上弼'
            ];
            var change = [];
            do
            {
                var aa = Math.floor(Math.random()*42);
                if($.inArray(city[aa], change)===-1){
                    change.push(city[aa])
                }
            }
            while (change.length<=4);

            alert("下拨星官将刷在这五个城池                   "+change);
        });
    });

</script>
</html>
